package com.ea.common.utils;

import com.ea.common.result.BizException;
import com.ea.common.result.ErrorCode;

import java.util.List;
import java.util.stream.Collectors;

public class ParamUtil {
    public static Long parseId(String id) {
        if (id == null || id.isEmpty()) return null;
        long result;
        try {
            result = Long.parseLong(id);
        } catch (Exception e) {
            throw new BizException(ErrorCode.USER_PARAM_ERROR_ID_ERROR);
        }
        return result;
    }

    public static List<Long> parseIdList(List<String> idList) {
        if (idList == null || idList.isEmpty()) return null;
        return idList.stream().map(ParamUtil::parseId).collect(Collectors.toList());
    }
}
